<template>
  <div class="noun">
    <div class="row container">
      <div class="main flex-grow-1">
        <NoneAbout :list="jobFairMessage.rows" text="招聘会"></NoneAbout>
        <ul class="row fww main-list">
          <li v-for="item in jobFairMessage.rows" :key="item.id">
            <el-card :body-style="{ padding: '0px' }">
              <img :src="BASEURL + item.banner" alt="">
              <div style="padding: 14px;" class="row">
                <div class="flex-grow-1 content">
                  <div class="title" @click="handleToJobFairInfo(item)">{{item.jobFairName}}</div>
                  <p>开始时间： {{item.startTime}}</p>
                  <p>结束时间： {{item.endTime}}</p>
                  <p>大厅LIVE：{{item.onlinecompany}}家企业， {{item.onlineperson}}位求职者</p>
                </div>
                <div style="padding-left: 10px; border-left: 1px dashed #bfbfbf;">
                  <div class="iconfont icon-yijieshu" v-if="item.status == 0" style="color: #ccc; transform: scale(.78);-webkit-transform: scale(.78);"></div>
                  <div class="iconfont icon-zhengzaijinxing" v-if="item.status == 1" style="color: red;"></div>
                  <div class="iconfont icon-jijiangkaishi" v-if="item.status == 2" style="color: green;"></div>
                  <JoinFairButton
                   size="small" 
                   type="danger"
                   :jobFairId="item.jobFairId" 
                   :info="item"
                  ></JoinFairButton>
                </div>
              </div>
            </el-card>
          </li>
          
        </ul>
        <div class="row jcc" style="margin: 15px 0;" v-if="jobFairMessage.rows.length !== 0">
           <el-pagination
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage"
          :page-size="10"
          layout="prev, pager, next, jumper"
          :total="jobFairMessage.total">
        </el-pagination>
        </div>
       
      </div>
      <div class="aside">
        <div class="hd-title">往期招聘会</div>
        <NoneAbout :list="beforeJobFairMessage.rows" text="往期招聘会"></NoneAbout>
        <ul>
          <li v-for="item in beforeJobFairMessage.rows" :key="item.index">
            <div class="row s-main">
              <img :src="BASEURL + item.banner" alt="">
              <div>晋中学院2019年届毕业生网络招聘会邀请函</div>
            </div>
            <p>开始时间：{{item.startTime}}</p>
            <p>结束时间：{{item.endTime}}</p>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import JoinFairButton from '@/components/JoinFairButton.vue'
import NoneAbout from '@/components/NoneAbout.vue'
import { BASEURL } from "@/api/";
import sock from '@/common/socket'
  export default {
    computed: {
      jobFairMessage(){
        this.total = this.$store.state.home.jobFairMessage.total
        this.beforeJobFairList = this.$store.state.home.jobFairMessage.total
        return this.$store.state.home.jobFairMessage
      },
      beforeJobFairMessage(){
        return this.$store.state.home.beforeJobFairMessage
      }
    },
    methods: {
      handleCurrentChange(val) {
        this.getjobFairList(this.currentPage);
        this.getbeforeJobFairList();
        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          // background: 'rgba(0, 0, 0, 0.7)'
        });
        setTimeout(() => {
          loading.close();
        }, 500);
      },
      handleToJobFairInfo(item){
        console.log(item,'--------------------')
        this.$router.push({path: `/jobfairinfo/${item.jobFairId}`})
      },
      async getjobFairList(page){
        let _data = {pageSize: 9, pageNumber: page, keyword: '', status: ['1', '2'], param3: localStorage.getItem("city")? localStorage.getItem("city") :this.$store.state.home.city }
        await this.$store.dispatch('getjobFairList',_data)
      },
      async getbeforeJobFairList(){
        let _data = {pageSize: 9, pageNumber: 1, keyword: '', status: ['0'], param3: localStorage.getItem("city")? localStorage.getItem("city") :this.$store.state.home.city }
        await this.$store.dispatch('getjobFairList',_data)
      },

      getUserNum(){
        let jobFairId = [];
        if(this.jobFairMessage.rows == undefined) return;
        if(this.jobFairMessage.rows.length == 0) return;
        jobFairId = this.jobFairMessage.rows
                    .map(val=>val.status == '1' && val.jobFairId)
                    .filter(val=>val!==false);
        sock.emit('getUserNum', {jobFairId:jobFairId});
        sock.on('listUserNum', (res)=>{
          this.$store.dispatch('getUserNumList',{res, jobFairId,})
        })
      }
    },
    data(){
      return {
        currentPage: 1,
        fullscreenLoading: false,
        total: 0,
        beforeJobFairList: [],
        BASEURL,
      }
    },
    async mounted(){
      await this.getbeforeJobFairList();
      await this.getjobFairList(this.currentPage);
      await this.getUserNum();
    },
    components:{
      JoinFairButton,
      NoneAbout,
    }
  }
</script>
<style lang="less">
.noun {
  .container {
    width: 1200px;
    margin: 0 auto;
  }

  .main {
    .main-list {
      li {
        width: 33.33%;
        padding-right: 15px;
        line-height: 1;
        margin-bottom: 15px;
        img {
          width: 100%;
        }

        .content {
          margin-right: 10px;
          .title {
            line-height: 1.5;
            cursor: pointer;
          }
          p{
            font-size: 12px;
            line-height: 1.3;
            color: #949494;
            &:first-of-type{
              margin-top: 5px;
            }
          }
          
        }
        .iconfont {
            font-size: 50px;
            text-align: center;
            margin-bottom: 15px;
        }
      
      }
    }
  }

  .aside {
    width: 250px;
    min-width: 250px;
    border: 1px solid #eee;
    // background: #f5fafb;
    .hd-title {
      text-align: center;
      line-height: 3;
      color: #409EFF;
      border-bottom: dashed #eee 1px;
    }
    ul li {
      padding: 14px;
      border-bottom: 1px solid #eee;
      .s-main {
        font-size: 13px;
        margin-bottom: 7px;
        img {
          width: 90px;
          height: 60px;
          display: block;
          margin-right: 10px;
        }
      }
      p {
        font-size: 13px;
        line-height: 1.3;
        color: #949494;
      }
    }
  }
}
</style>

